package lab04;
import java.util.Scanner;


// 求斐波那契 fibonacci sequence 数列第 n 项值，n 为用户输入的正整数
public class Fibonacci {

    // 0, 1, 1, 2, 3, 5,...

    private static long getFibonacci(int n) {
        if (n == 1) {
            return 0;
        }
        if (n == 2) {
            return 1;
        }
        return getFibonacci(n - 1) + getFibonacci(n - 2);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("input n: ");
        int n = scanner.nextInt();
        System.out.println("F(" + n + ") = " + getFibonacci(n));
    }
}